﻿using System;
using UniRx;
using UnityEngine;

namespace YK
{
	// Token: 0x0200012D RID: 301
	public static class AssetUtility
	{
		// Token: 0x060006CC RID: 1740 RVA: 0x00028448 File Offset: 0x00026648
		public static T LoadAsset<T>(AssetBundleInfo info) where T : UnityEngine.Object
		{
			return AssetUtility.LoadAsset<T>(info.AssetBundleName, info.AssetName, info.AssetBundleManifestName);
		}

		// Token: 0x060006CD RID: 1741 RVA: 0x00028464 File Offset: 0x00026664
		public static T LoadAsset<T>(string assetbundleName, string assetName, string manifestName = "") where T : UnityEngine.Object
		{
			manifestName = ((!manifestName.IsNullOrEmpty()) ? manifestName : null);
			T result = CommonLib.LoadAsset<T>(assetbundleName, assetName, false, manifestName);
			AssetBundleManager.UnloadAssetBundle(assetbundleName, true, manifestName, false);
			return result;
		}

		// Token: 0x060006CE RID: 1742 RVA: 0x0002849C File Offset: 0x0002669C
		public static UniRx.IObservable<T> LoadAssetAsync<T>(string assetBundleName, string assetName, string manifestName = "", UniRx.IProgress<float> progress = null) where T : UnityEngine.Object
		{
			if (!AssetBundleCheck.IsFile(assetBundleName, assetName))
			{
				string message = "読み込みエラー\r\nassetBundleName: " + assetBundleName + "\tassetName: " + assetName;
				GlobalData.Debug_LogWarning(message);
				return Observable.Empty<T>();
			}
			AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(T), manifestName);
			if (request == null)
			{
				string message2 = "読み込みエラー\r\nassetName: " + assetName;
				GlobalData.Debug_LogError(message2);
				return Observable.Empty<T>();
			}
			return Observable.FromCoroutine<T>((UniRx.IObserver<T> observer) => request);
		}
	}
}
